package com.jx.cashier.rest.http;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ta.util.TALogger;
import com.ta.util.http.AsyncHttpResponseHandler;

public class JxDccRestResponse {
	private ObjectMapper mapper = new ObjectMapper();
	
	public void onSuccess(String content)
	{
		JsonNode root = null;
		if ( content != null ) {
			try {
				root = mapper.readTree(content);
			} catch (Exception e) {
				TALogger.e("response parse json fail", e.getMessage());
			}
			if ( !root.has("data")) {
				TALogger.e("response","no data");
			}
			else{
				JsonNode data = root.get("data");
				onSuccess(data, root);
			}
		}
		else {
			TALogger.e("response","response is empty");
		}
	}

	public void onSuccess(JsonNode data, JsonNode root){

	}

	public void onFailure(Exception e) {
	}

	public void onFailure(Exception error, String content) {
		this.onFailure(error);
	}

}